﻿@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Chloe后台登录</title>
    <link href="~/Content/font-awesome/font-awesome.min.css" rel="stylesheet" />
    <link href="~/Content/css/framework-login.css" rel="stylesheet" />

    <script src="~/Content/jquery/jquery-1.11.1.min.js"></script>

    <script src="~/Content/jquery/jquery.cookie.js"></script>
    <script src="~/Content/jquery/jquery.md5.js"></script>
    <script src="~/Content/js/ace.js"></script>

    <!--[if lte IE 8]>
        <div id="errorie"><div>您还在使用老掉牙的IE，正常使用系统前请升级您的浏览器到 IE8以上版本 <a target="_blank" href="http://windows.microsoft.com/zh-cn/internet-explorer/ie-8-worldwide-languages">点击升级</a>&nbsp;&nbsp;强烈建议您更改换浏览器：<a href="http://down.tech.sina.com.cn/content/40975.html" target="_blank">谷歌 Chrome</a></div></div>
    <![endif]-->
</head>
<body>
    <div style="position: absolute; z-index: 999; top: 20px; left: 20px; color: #fff; font-size: 13px; line-height: 22px;">
        此站点为 Chloe.ORM 官网 <a href="http://www.52chloe.com/" target="_blank">http://www.52chloe.com</a> 线上后台，基于 ASP.NET Core 开发，部署于阿里云 Linux 服务器。<br>
        访客登录名 52chloe ，密码 52chloe。请勿在系统内发表不文明信息，使用 52chloe 帐号登录看到的信息均为官网在线数据，也恳请大家别乱删除系统内已有的数据，谢谢！
    </div>

    <div class="wrapper">
        <div class="container">
            <div class="logo">
                <i class="fa fa-modx"></i>
                <h1><span>Chloe</span>后台登录</h1>
            </div>
            <form class="form">
                <div class="row">
                    <input id="txt_account" type="text" placeholder="用户名/手机号/邮箱">
                    <i class="fa fa-user"></i>
                </div>
                <div class="row">
                    <input id="txt_password" type="password" placeholder="登录密码">
                    <i class="fa fa-key"></i>
                </div>
                @*<div class="row">
                        <input id="txt_code" maxlength="4" type="text" placeholder="验证码" style="width: 190px; float: left;">
                        <div style="width: 110px; float: right; padding-top: 14px; padding-left: 14px;">
                            看不清？<a id="switchCode" href="javascript:void();" style="text-decoration: none;">换一张</a>
                            <img id="imgcode" class="authcode" src="@this.Href("~/Account/VerifyCode")" width=" 80" height="25" />
                        </div>
                    </div>*@
                <div class="row">
                    <button id="login_button" type="button"><span>登录</span></button>
                </div>
                <div class="row">
                </div>
            </form>
            <div class="login_tips"></div>
        </div>
        <ul class="bg-bubbles">
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </div>
    <div class="copyright">
        适用浏览器：IE8以上、360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗.
    </div>
    <script type="text/javascript">
        (function ($) {
            $.login = {
                formMessage: function (msg) {
                    $('.login_tips').find('.tips_msg').remove();
                    $('.login_tips').append('<div class="tips_msg"><i class="fa fa-question-circle"></i>' + msg + '</div>');
                },
                loginClick: function () {

                    var $userName = $("#txt_account");
                    var $password = $("#txt_password");
                    var $code = $("#txt_code");
                    if ($userName.val() == "") {
                        $userName.focus();
                        $.login.formMessage('请输入用户名/手机号/邮箱。');
                        return false;
                    } else if ($password.val() == "") {
                        $password.focus();
                        $.login.formMessage('请输入登录密码。');
                        return false;
                    }
                    //else if ($code.val() == "") {
                    //    $code.focus();
                    //    $.login.formMessage('请输入验证码。');
                    //    return false;
                    //}
                    else {
                        $("#login_button").attr('disabled', 'disabled').find('span').html("loading...");
                        var params = { loginName: $.trim($userName.val()), password: $.md5($.trim($password.val())), verifyCode: $.trim($code.val()) };
                        $.ajax({
                            url: "@this.Href("~/Account/Login")",
                            data: params,
                            type: "post",
                            dataType: "json",
                            success: function (data) {
                                if (data.Status == ResultStatus.OK) {
                                    $("#login_button").find('span').html("登录成功，正在跳转...");
                                    window.setTimeout(function () {
                                        var returnUrl = $ace.getQueryParam("returnUrl");
                                        if (returnUrl)
                                            window.location.href = returnUrl;
                                        else
                                            window.location.href = "@this.Href("~/")";
                                    }, 500);
                                } else {
                                    $("#login_button").removeAttr('disabled').find('span').html("登录");
                                    $("#switchCode").trigger("click");
                                    $code.val('');
                                    $.login.formMessage(data.Msg);
                                }
                            }
                        });
                    }
                },
                init: function () {
                    $('.wrapper').height($(window).height());
                    $(".container").css("margin-top", ($(window).height() - $(".container").height()) / 2 - 50);
                    $(window).resize(function (e) {
                        $('.wrapper').height($(window).height());
                        $(".container").css("margin-top", ($(window).height() - $(".container").height()) / 2 - 50);
                    });
                    $("#switchCode").click(function () {
                        $("#imgcode").attr("src", "@this.Url.Content("~/Account/VerifyCode?t=")" + Math.random());
                    });
                    var login_error = top.$.cookie('login_error');
                    if (login_error != null) {
                        switch (login_error) {
                            case "overdue":
                                $.login.formMessage("系统登录已超时,请重新登录");
                                break;
                            case "OnLine":
                                $.login.formMessage("您的帐号已在其它地方登录,请重新登录");
                                break;
                            case "-1":
                                $.login.formMessage("系统未知错误,请重新登录");
                                break;
                        }
                        top.$.cookie('login_error', '', { path: "/", expires: -1 });
                    }

                    $("#txt_account").focus();

                    $("#login_button").click(function () {
                        $.login.loginClick();
                    });
                    document.onkeydown = function (e) {
                        if (!e) e = window.event;
                        if ((e.keyCode || e.which) == 13) {
                            document.getElementById("login_button").focus();
                            document.getElementById("login_button").click();
                        }
                    }
                }
            };
            $(function () {
                $.login.init();
            });
        })(jQuery);
    </script>
</body>
</html>
